package com.gzh.controller;

import com.gzh.mapper.UserMapper;
import com.gzh.pojo.User01;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.jdbc.core.BeanPropertyRowMapper;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import java.util.List;

@Slf4j
@Controller
public class UserTestController {
    @Autowired
    JdbcTemplate jdbcTemplate;

    @Autowired
    UserMapper userMapper;

    @RequestMapping("show")
    public ResponseEntity<Void> show(){
        List<User01> query = jdbcTemplate.query("SELECT * FROM user", new BeanPropertyRowMapper<User01>(User01.class));
        log.info("测试jdbcTemplate默认设置");
        for (User01 user01 : query) {
            System.out.println(user01);
        }

        User01 userById = userMapper.findUserById(1);
        System.out.println(userById);


        return null;
    }
}
